import { qaRecommendSubmit,baseQaRecommendProcess,qaRecommendList,baseQaRecommendStatus,knowledgeQuestionList,knowledQuestionTemplateList,knowledQuestionTemplateValues,knowaddQuestion } from '@/services/knowledgemanagement';

export default {
  namespace:'extendRt',

  state: {

  },

  // ----- extendRt------
  effects: {
    *fetch({ payload, callback }, { call, put }) {  //
      const response = yield call(knowledQuestionTemplateList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchb({ payload, callback }, { call, put }) { // 
      const response = yield call(knowledQuestionTemplateValues, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *fetchc({ payload, callback }, { call, put }) { // 添加相似批量问
      const response = yield call(knowaddQuestion, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *knowledgeQuestionList({ payload, callback }, { call, put }) { // 添加相似批量问
      const response = yield call(knowledgeQuestionList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *baseQaRecommendStatus({ payload, callback }, { call, put }) { // 获取知识点问题推荐任务状态
      const response = yield call(baseQaRecommendStatus, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *baseQaRecommendProcess({ payload, callback }, { call, put }) { // 获取知识点问题推荐任务进度
      const response = yield call(baseQaRecommendProcess, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *qaRecommendList({ payload, callback }, { call, put }) { // 获取知识点问题推荐任务结果列表
      const response = yield call(qaRecommendList, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
    *qaRecommendSubmit({ payload, callback }, { call, put }) { // 知识库管理 提交知识点问题推荐任务
      const response = yield call(qaRecommendSubmit, payload);
      if (response) {
        if (callback && typeof callback === 'function') {
          callback(response);
        }
        yield put({
          type: 'save',
          payload: response,
        });
      }
    },
  },

  // ----- leftTree结束------

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
    clear() {
      return {

      };
    },
  },
};
